﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace SiteFox.Business.Manager
{
    public static class Site
    {
        public static Model.Site Get()
        {
            var _Entities = new Model.Entities(Data.WebConfig.GetConnectionString());
            var _Query = from c in _Entities.Site where c.ID == 0 select c;
            return _Query.FirstOrDefault();
        }
        public static void Edit(Model.Site _Site)
        {
            using (var _Entities = new Model.Entities(Data.WebConfig.GetConnectionString())) 
            {
                var __Site = _Entities.Site.First(c => c.ID == 0);
                __Site.Author = _Site.Author;
                __Site.Copyrights = _Site.Copyrights;
                __Site.Description = _Site.Description;
                __Site.EmailSmtpFrom = _Site.EmailSmtpFrom;
                __Site.EmailSmtpHost = _Site.EmailSmtpHost;
                __Site.EmailSmtpPassword = _Site.EmailSmtpPassword;
                __Site.EmailSmtpUsername = _Site.EmailSmtpUsername;
                __Site.GenerateMeta = _Site.GenerateMeta;
                __Site.Keywords = _Site.Keywords;
                __Site.ReVisit = _Site.ReVisit;
                __Site.RobotToDo = _Site.RobotToDo;
                __Site.Title = _Site.Title;
                __Site.WelcomePagePath = _Site.WelcomePagePath;
                _Entities.SaveChanges();
            }
        }
    }
}

